<template>
  <div>
    <p>用户名:<input type="text" v-model="username"></p>
    <p>密码:<input type="text" v-model="password"></p>
    <p><button @click="btn">登录</button></p>
  </div>

</template>

<script>
    export default {
        name: "Login",
        data(){
          return{
            username:'',
            password:'',
          }
        },
        methods:{
          btn(){
            let form_data=new FormData()
            formdata.append('username',this.username)
            formdata.append('password',this.password)
            this.axios({
              url:'http://127.0.0.1:8000/app01/login/',
              method:'post',
              data:formdata
            }).then(res=>{
              console.log(res)
              if (res.data.code==1000){
              sessionStorage.setItem('token',res.data.token)
              this.$router.push('/AddUser')}
            })
          }
        },
    }
</script>

<style scoped>

</style>